﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="UserSearch.ascx.cs" Inherits="admin_webparts_Plug_ins_User2_UserSearch" %>
<%@ Import Namespace="NTTHAO.Web.BL.Authentication" %>
<style type="text/css">
    #spSearch {font-size:1.1em; font-weight: bold; }
    #spSearch button { font-family: Verdana,Arial,Helvetica,sans-serif; font-weight: bold; }
</style>
<script type="text/javascript">
    YAHOO.util.Event.onContentReady("spSearch", function () {
        var spSave = new YAHOO.widget.Button("spSearch");
        document.getElementById('<%=txtUsername.ClientID %>').focus();
    });
</script>
<div class="tip" style="margin-bottom: 3px;">
    <h2 style="left: 0px; position: relative; padding-top: 0px; margin-bottom: 15px;">Tìm kiếm người dùng</h2>
    <form id="frmSearch" method="post" action="default.aspx?type=page&name=user&action=search" runat="server">
    <table border="0" cellpadding="1" cellspacing="0">
        <tr>
            <td>Nhập tên đăng nhập cần tìm:</td>
            <td style="width: 10px;"></td>
            <td>
                <asp:TextBox ID="txtUsername" runat="server" Width="200px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td>Hoặc email của người dùng:</td>
            <td style="width: 10px;"></td>
            <td>
                <asp:TextBox ID="txtEmail" runat="server" Width="200px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td>Hoặc số điện thoại:</td>
            <td style="width: 10px;"></td>
            <td>
                <asp:TextBox ID="txtPhoneNumber" runat="server" Width="200px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td></td>
            <td>
                <span id="spSearch" class="yui-button yui-link-button"><span class="first-child"><asp:Button ID="btnSearch" runat="server" OnClick="btnSearch_Click" Text="Tìm kiếm" /></span></span>
            </td>
        </tr>
    </table>
    </form>
</div>
<%if (_ResultTotal > -1) { %>
<div style="border: solid 1px #89F;font-weight: bold; padding: 5px;margin-bottom: 3px;">Tìm thấy <span style="color: #E76300;"><%=_ResultTotal %></span> kết quả</div>
<%if (_ResultTotal > 0) {
      %>
<table border="1" cellpadding="0" cellspacing="0" class="grid">
    <tr>
        <th>STT</th>
        <th>Tên</th>
        <th>Email</th>
        <th>Điện thoại</th>
        <th>Ngày đăng ký</th>
        <th>Tình trạng</th>
        <th style="white-space: nowrap; width: 1px;">Chức năng</th>
    </tr>
<%
    int index = 0;
    if (_User != null) {
        string userTitle = UserTitle.GetTitle(_User.UserTitle);
        if (userTitle == string.Empty)
        {
            userTitle = "-";
        }
        index++;
        %>
    <tr class="<%=index % 2 == 0 ? "even" : "odd"%>">
        <td class="center"><%=index %></td>
        <td><%= "(" + userTitle + ") " + _User.FullName%></td>
        <td><a href="mailto:<%=_User.UserName %>"><%=_User.UserName %></a></td>
        <td class="center"><%=_User.MobilePhone %></td>
        <td class="center"><%=_User.JoinDate.ToString("HH:mm dd/MM/yyyy")%></td>
        <td class="center"><%=UserStatus.GetStatusName(_User.StatusID) %></td>
        <td>
            <ul class="icon" style="width: 84px;">
                <li><a class="icon detailbtn" title="Chi tiết" href="?type=page&name=user&action=detail&user=<%=_User.UserName%>">&nbsp;</a></li>
<%if (_User.StatusID == UserStatus.INACTIVE || _User.StatusID == UserStatus.PAUSED) { %>
                <li><a class="icon activebn" title="Kích hoạt tài khoản" href="?type=page&name=user&action=active&user=<%=_User.UserName%>">&nbsp;</a></li>
<%} %>
<%if (_User.StatusID == UserStatus.INACTIVE || _User.StatusID == UserStatus.ACTIVATED)
  { %>
                <li><a class="icon inactivebn" title="Khóa tài khoản" href="?type=page&name=user&action=deactive&user=<%=_User.UserName%>">&nbsp;</a></li>
<%} %>
            </ul>
        </td>
    </tr>
<%
    }
    if (_SearchResult != null)
    {
        foreach (System.Data.DataRow row in _SearchResult.Rows)
        {
            int id = (int)row[User.ID__COLUMN_NAME];
            int title = (int)row[User.USERTITLE__COLUMN_NAME];
            string fullName = row[User.FULLNAME__COLUMN_NAME].ToString();
            string email = (string)row[User.USERNAME__COLUMN_NAME];
            string mobilePhone = row[User.MOBILEPHONE__COLUMN_NAME].ToString();
            DateTime joinDate = (DateTime)row[User.JOINDATE__COLUMN_NAME];
            int statusID = (int)row[User.STATUSID__COLUMN_NAME];
            string userTitle = UserTitle.GetTitle(title);
            if (userTitle == string.Empty)
            {
                userTitle = "-";
            }
            index++;
        %>
    <tr class="<%=index % 2 == 0 ? "even" : "odd"%>">
        <td class="center"><%=index %></td>
        <td><%= "(" + userTitle + ") " + fullName%></td>
        <td><a href="mailto:<%=email %>"><%=email%></a></td>
        <td class="center"><%=mobilePhone %></td>
        <td class="center"><%=joinDate.ToString("HH:mm dd/MM/yyyy")%></td>
        <td class="center"><%=UserStatus.GetStatusName(statusID) %></td>
        <td>
            <ul class="icon" style="width: 84px;">
                <li><a class="icon detailbtn" title="Chi tiết" href="?type=page&name=user&action=detail&user=<%=email%>">&nbsp;</a></li>
<%if (statusID == UserStatus.INACTIVE || statusID == UserStatus.PAUSED)
  { %>
                <li><a class="icon activebn" title="Kích hoạt tài khoản" href="?type=page&name=user&action=active&user=<%=email%>">&nbsp;</a></li>
<%} %>
<%if (statusID == UserStatus.INACTIVE || statusID == UserStatus.ACTIVATED)
  { %>
                <li><a class="icon inactivebn" title="Khóa tài khoản" href="?type=page&name=user&action=deactive&user=<%=email%>">&nbsp;</a></li>
<%} %>
            </ul>
        </td>
    </tr>
<%
        }
    }
%>
</table>
<%} %>
<%} %>
